﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SendSMS
{
    public static class SysLog
    {
        public static string FilePath = @"C:\sms\SysLog\Log.txt";
        public static void WriteSysLog(string sm)
        {
            if (File.Exists(FilePath))
            {
                StreamWriter sw = new StreamWriter(FilePath, true);
                sw.WriteLine("Time:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                sw.WriteLine(sm);
                sw.WriteLine("------------------------------------------------------------------------------");
                sw.WriteLine("\r");
                sw.Close();
                return;
            }
            else
            {
                File.Create(FilePath);
                StreamWriter sw2 = new StreamWriter(FilePath, true);
                sw2.WriteLine("Time:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                sw2.WriteLine(sm);
                sw2.WriteLine("------------------------------------------------------------------------------");
                sw2.WriteLine("\r\n");
                sw2.Close();
                return;
            }
        }

    }
}
